<?php

// 页面显示框架

class IndexAction extends CommonAction {
	
	public function index(){

		if(session('account'))
		{
			$this->show();
		}else
		{
			$this->display('Public/login');
		}
		
	}

	public function top(){
		$m=M('admin_power');
		
		//$condition = array();
		//$condition['level'] = 0;
		//$condition['status']= 1;
		//$nav = $m->where($condition)->order('id asc')->select();
		
		$nav = $m->where('level=0 and status=1')->order('id asc')->select();
		
		$this->assign('navs',$nav);
		$this->show();
	}

	public function left(){
		
		$navid = $this->_get('id') ? $this->_get('id') : 1;
		$m = M('admin_power');
		//$condition = array();
		//$condition['p_id'] = $navid;
		//$condition['status'] = 1;
		//$navs = $m->where($condition)->order('level asc')->select();
		
		///*
		$navs = $m->where(' p_id = '.$navid.' and status=1 ')->order('level asc')->select();
		
		//$sql = 'select * 
		//		from '.$m->getTableName().' 
		//		where p_id='.$navid.' and status=1 order by level asc';
		//$navs = $m->query( $sql );
			
		//echo $m->_sql();
		foreach($navs as $key=>$val)
		{
			$sub_navs = $m->where(' p_id = '.$val['id'].' and status=1 ')->order('`order` asc')->select();
			//print_r($sub_navs);
			$navs[$key]['sub_navs'] = $sub_navs;
		}
		

		$this->assign('navs',$navs);
		$this->display();
	}

	public function main(){
		
		$this->show();
	}

	public function change(){
		$this->show();
	}

	public function footer()
	{
		$this->display();
	}
	

}